package System;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.border.TitledBorder;
import java.awt.SystemColor;

/**
 * This class is the Gui to present while server is running
 *
 */
public class ServerOnGUI extends JPanel implements ActionListener
{
	public JTextArea textArea;
	private JButton btnExit;

	/**
	 * Create the panel.
	 */
	public ServerOnGUI() 
	{
		super();
		initialize();
	}
	
	private void initialize()
	{
		setBorder(new TitledBorder(null, "Server", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		setBackground(SystemColor.activeCaption);
		setBounds(300,200,494,448);
		setLayout(null);
		
		textArea = new JTextArea();
		textArea.setEnabled(false);
		textArea.setEditable(false);
		textArea.setBackground(Color.WHITE);
		textArea.setBounds(25, 68, 434, 333);
		add(textArea);
		
		JLabel lblServerIsOn = new JLabel("Server is On");
		lblServerIsOn.setFont(new Font("Microsoft New Tai Lue", Font.BOLD, 20));
		lblServerIsOn.setBounds(183, 25, 123, 32);
		add(lblServerIsOn);
		
		ImageIcon icon = new ImageIcon("Icons\\Logout.png");
		btnExit = new JButton(icon);
		btnExit.setBounds(385, 43,icon.getIconWidth(),icon.getIconHeight());
		btnExit.addActionListener(this);
		add(btnExit);
		
		JRadioButton radioButton = new JRadioButton("");
		radioButton.setSelected(true);
		radioButton.setBounds(164, 25, 109, 30);
		radioButton.setBackground(this.getBackground());
		radioButton.setEnabled(false);
		add(radioButton);
		
		
	}

	@Override
	public void actionPerformed(ActionEvent e) 
	{
		if (e.getSource() == btnExit)
		{
			Server.terminateServer();
			textArea.setText(null);
		}
	}
}
